Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Replace Buffer with TextEncoder/TextDecoder for mobile comptability #94

Closed

Conversation

joseporiolcarne
Copy link

  • Replaced the use of Buffer with TextEncoder and TextDecoder in the pretty function for mobile comptability
  • Added comments explaining that Buffer is not compatible with mobile versions of Obsidian due to reliance on Node.js-specific APIs.
  • Ensures UTF-8 encoding is maintained without breaking compatibility across different environments.

…ompatibility

- Replaced the use of Buffer with TextEncoder and TextDecoder in the pretty function.
- Added comments explaining that Buffer is not compatible with mobile versions of Obsidian due to reliance on Node.js-specific APIs.
- Ensures UTF-8 encoding is maintained without breaking compatibility across different environments.
@joseporiolcarne
Copy link
Author

This commit addresses the Uncaught (in promise) ReferenceError: Buffer is not defined error that occurs when using the plugin on mobile devices, specifically on Android. The error prevents the calendar from updating in the Gist or the file, and it does not appear on desktop environments.
Issue Details:

What I found is that error occurs because Buffer is a Node.js-specific API, which is not available in environments like mobile versions of Obsidian
This issue was observed on a Xiaomi 11 running Android, where the calendar would not update as expected.
The error does not appear in desktop environments such as Windows 11 and Lubuntu 24.04, where Buffer is supported.

Solution:

Replaced the Buffer usage with TextEncoder and TextDecoder, which are compatible across all environments, including mobile versions of Obsidian.
I tested the changes on Android (Xiaomi 11), Windows 11, and Lubuntu 24.04, confirming that the calendar updates correctly across these platforms without triggering the error.

@joseporiolcarne joseporiolcarne closed this by deleting the head repository Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant